﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using umbraco.interfaces;

namespace ProlificNotion.Umbraco.MediaImporter
{
    public class ImportMediaAction : IAction
    {
        /// <summary>
        /// Create a singleton
        /// </summary>
        private static readonly ImportMediaAction instance = new ImportMediaAction();

        /// <summary>
        /// Initializes a new instance of the <see cref="SortAction"/> class.
        /// </summary>
        private ImportMediaAction() { }

        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <value>The instance.</value>
        public static ImportMediaAction Instance
        {
            get { return instance; }
        }

        #region IAction Members

        /// <summary>
        /// Each IAction needs to be assigned a letter and they all need to be unique.
        /// </summary>
        public char Letter
        {
            get { return 'þ'; }
        }

        /// <summary>
        /// Gets a value indicating whether [show in notifier].
        /// </summary>
        /// <value><c>true</c> if [show in notifier]; otherwise, <c>false</c>.</value>
        public bool ShowInNotifier
        {
            get { return true; }
        }

        /// <summary>
        /// Set this to true if the menu item can be permission assignable. If set to false,
        /// the menu item will show up for all users.
        /// </summary>
        public bool CanBePermissionAssigned
        {
            get { return false; }
        }

        /// <summary>
        /// Gets the icon.
        /// </summary>
        /// <value>The icon.</value>
        public string Icon
            {
                get { return "images/umbraco/drive_go.png"; }
        }

        /// <summary>
        /// Gets the alias.
        /// </summary>
        /// <value>The alias.</value>
        public string Alias
        {
            get { return "Import Media from Server"; }
        }

        /// <summary>
        /// This is a path to a JavaScript file that contains the custom JavaScript to call.
        /// </summary>
        public string JsSource
        {
            get { return String.Empty; }
        }

        /// <summary>
        /// This is the method to call in the custom JavaScript file. The JavaScript file will 
        /// be rendered out in the parent frame
        /// so the call to the method needs to be prefixed with "parent." Since the JavaScript 
        /// file is rendered out in the parent frame
        /// the script will have access to the properties of the umbracoDefault.js script    
        /// which contains properties such as nodeID (which is
        /// the id of the node that is use has right clicked).
        /// </summary>
        public string JsFunctionName
        {
            get { return "openModal('dialogs/ImportMedia.aspx?id=' + nodeID, 'Import Media', 450, 550);"; }
        }

        #endregion
    }
}
